翻訳と辞書
Words near each other
・ Folch solution
・ Folchard Psalter
・ Folck's Mill
・ Folcmar (bishop)
・ Folco
・ Folco de Baroncelli-Javon
・ Folco Lulli
・ Folco Portinari
・ Folco Quilici
・ Folcric
・ Folcroft (SEPTA station)
・ Folcroft, Pennsylvania
・ Folcwald
・ Fold (album)
・ Fold (geology)
Fold (higher-order function)
・ Fold (Unix)
・ Fold A to B
・ Fold and thrust belt
・ Fold change
・ Fold equity
・ Fold Island
・ Fold mountain
・ Fold number
・ Fold of left vena cava
・ Fold Villages
・ Fold Your Hands Child, You Walk Like a Peasant
・ Fold Zandura
・ Fold-and-cut theorem
・ Fold-forming


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Fold (higher-order function) : ウィキペディア英語版
Fold (higher-order function)
In functional programming, fold – also known variously as reduce, accumulate, aggregate, compress, or inject – refers to a family of higher-order functions that analyze a recursive data structure and through use of a given combining operation, recombine the results of recursively processing its constituent parts, building up a return value. Typically, a fold is presented with a combining function, a top node of a data structure, and possibly some default values to be used under certain conditions. The fold then proceeds to combine elements of the data structure's hierarchy, using the function in a systematic way.
Folds are in a sense dual to unfolds, which take a "seed" value and apply a function corecursively to decide how to progressively construct a corecursive data structure, whereas a fold recursively breaks that structure down, replacing it with the results of applying a combining function at each node on its terminal values and the recursive results (catamorphism as opposed to anamorphism of unfolds).
==Folds as structural transformations==

Folds can be regarded as consistently replacing the structural components of a data structure with functions and values. Lists, for example, are built up in many languages from two primitives: any list is either an empty list, commonly called ''nil''  (. Note that the parameters to cons must be flipped, because the element to add is now the right hand parameter of the combining function. Another easy result to see from this vantage-point is to write the higher-order map function in terms of foldr, by composing the function to act on the elements with cons, as:

map f = foldr ((:) . f) []

where the period (.) is an operator denoting function composition.
This way of looking at things provides a simple route to designing fold-like functions on other algebraic data structures, like various sorts of trees. One writes a function which recursively replaces the constructors of the datatype with provided functions, and any constant values of the type with provided values. Such a function is generally referred to as a catamorphism.

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Fold (higher-order function)」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.